#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N = 110;
int arr[N];
int hash1[N];
int n, c;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> c;
		memset(arr, 0, sizeof(arr));
		memset(hash1, 0, sizeof(hash1));
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
			hash1[arr[i]]++;
		}
		int ans = 0;
		for (int i = 1; i <= 100; i++) {
			if (hash1[i] >= 1) {
				ans += min(hash1[i], c);
			}
		}
		cout << ans << endl;
	}
}